// pages/sqzp/sqzp.js
const app = getApp()
const db = wx.cloud.database();
const _ = db.command;
var util = require('../../utils/time.js')
Page({
    /**
     * 页面的初始数据
     */
    data: {
        admin_send: "",
        user_address:"广东省深圳市坪山区深圳技术大学"
    },

    onLoad: function (options) {
        this.setData({
            user_address:options.address
        })
    },
    //admin_send快递单号输入
    input1: function (data) {
        this.setData({
                admin_send: data.detail.value
            }),
            console.log("admin_send:", this.data)
    },
    jilu() {
        wx.navigateTo({
            url: '/pages/sqzp2/sqzp2',
        })
    },
    submit() {
        console.log(this.data)
        let time2 = util.formatTime(new Date())
        if (!this.data.admin_send=='') {
            wx.cloud.callFunction({
                name: 'zpsqupdate',
                data: {
                    id: app.globalData.id,
                    admin_send: this.data.admin_send,
                    user_send:'',
                    time2
                },
                success: ress => {
                    console.log('添加快递号信息: ', ress)
                    wx.redirectTo({
                        url: '/pages/clzp/clzp',
                    })
                },
                fail: ress => {
                    console.log('添加快递信息失败: ', ress)
                    wx.showToast({
                        title: '添加快递信息失败',
                        icon: 'none'
                    })
                }
            })
        } else {
            wx.showToast({
                title: '请填写快递单号',
                icon: 'none'
            })
        }
    }
})